#import "FlutterLocationPlugin.h"
#import "LocationManager.h"

@implementation FlutterLocationPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
  FlutterMethodChannel* channel = [FlutterMethodChannel
      methodChannelWithName:@"flutter_location"
            binaryMessenger:[registrar messenger]];
    [LocationManager shareLocationManager];
  FlutterLocationPlugin* instance = [[FlutterLocationPlugin alloc] init];
  [registrar addMethodCallDelegate:instance channel:channel];
}

- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
    if([@"getLocation" isEqualToString:call.method]) {
      [self getLocation:call result:result];
    }
  else {
    result(FlutterMethodNotImplemented);
  }
}

- (void)getLocation:(FlutterMethodCall*)call result:(FlutterResult)result {
    [[LocationManager shareLocationManager] startUpdatingLocation:result];
}

@end
